<template>
	<view>
		<view class="warp">
			<view class="text-area">
				<u-search placeholder="请输入关键内容" shape="round" v-model="queryInfo.name" @click="getDocument"></u-search>
			</view>
		        <view class="box">
					<u-cell-group>
						<u-cell v-for="(item, index) in tableData" :key="index" :title="item.name" :arrow="false">
							<template slot="label">
								<span>{{"导入人："+item.importPeople}}</span>
							</template>
							<template slot="value">
								<u-icon name="trash" color="red" size="20px" @click="deleteDocument(item.id)"></u-icon>
							</template>
						</u-cell>
					</u-cell-group>
		        </view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				queryInfo: {
				        name: '',
						pagesize:20,
						pagenum:1,
				      },
				tableData:{},
				token:""
			}
		},
		created() {
			this.getDocument()
		},
		onLoad(){
			let that = this;
			uni.getStorage({
			    key: 'token',
			    success: function (res) {
					that.token = res.data
			    }
			});
		},
		methods: {
				getDocument() {
						const value = uni.getStorageSync('token');
						uni.request({
							//URL="www.baidu.com?" +“problem=”xxxx+"&data="+xxxx+"&request="+xxx;
						    url:"http://118.178.106.254:8081/SourceMaterial/getVeideoSourse?"+"name="+this.queryInfo.name+"&pageSize="+this.queryInfo.pagesize+"&pageNum="+this.queryInfo.pagenum,
							method:'get',
							header: {
								'Authorization':value,
							},
						    success: (res) => {
								this.tableData=res.data.data.list
						    }
						})
					},
					deleteDocument(id) {
							const value = uni.getStorageSync('token');
							uni.request({
							    url:"http://118.178.106.254:8081/SourceMaterial/deleteSourceMaterial?"+"id="+id,
								method:'DELETE',
								header: {
									'Authorization':value,
								},
							    success: (res) => {
									if(res.data.code!==401){
										title:'删除成功',
										this.getDocument()
									}
							    }
							})
						}
				},
			}
</script>

<style>
.text-area{
	margin-top: 20px;
}
.box{
	margin-top: 10px;
}
</style>
